//可选参数：date，year
//给定date则查本月月记，返回ID和CONTENT
//给定year则查一年所有的月记
def user = session.appUser();
def todayDate = new Date().format('yyyy-MM-dd');

def date = request.getString('date');
def month = request.getLong('month');
def year = request.getLong('year');

if (date != null) {
	def id = db.find("select ID from MONTH where OPEN_ID=? and DATE=?",user.openId,date);
	if (!id) {
		return false;
	} else {
		def content = db.find('select CONTENT from MONTH where ID=?',id.ID)
		if (content != null) {
			return [id: id, content: content];
			} else {
				return id;
			}
		
	}
} else if (month != null && year != null) {
	def result = db.query("select CONTENT,DATE from MONTH where MONTH(DATE) = ? and YEAR(DATE) = ?", month,year);
	log.debug('result:{}',result);
	return result;
}